package com.zl.smartmall.library.account.vo;

import java.util.List;

import net.tsz.afinal.FinalDb;

import org.json.JSONException;

import android.content.Context;

import com.zl.smartmall.library.account.po.CookieInfo;

public class CookieInfoDao {

	private FinalDb mFinalDb;
	
	public CookieInfoDao(Context context){
		mFinalDb = FinalDb.create(context);
	}
	
	public void insert(CookieInfo cookieInfo) throws JSONException {
		synchronized (CookieInfoDao.class) {
			mFinalDb.save(cookieInfo);
		}

	}
	
	public void delete() {
		synchronized (CookieInfoDao.class) {
			mFinalDb.deleteAll(CookieInfo.class);
		}
	}

	public CookieInfo query() {
		synchronized (CookieInfoDao.class) {
			List<CookieInfo> cookieInfos = mFinalDb.findAll(CookieInfo.class);
			if(cookieInfos != null && cookieInfos.size() > 0) {
				return cookieInfos.get(0);
			}
			return null;
		}
	}
	
}
